<template >
<el-card id="order_in_container"  v-if="Object.keys(order_inPage.data).length !== 0" shadow="always">
    <div id="store">
        <img src="../assets/cooker.webp" alt="logo" class="food-picture"/>
        <div>{{ order_inPage.data.user_name }}</div>
    </div>
    <div id="commodity"  v-for="(foodItem) in order_inPage.data.foodsInfo" :key="foodItem.foodName" class="food-commodity">
        <img :src="`${foodItem.picUrl}`" alt="01" />
        <span class="food-name">{{foodItem.foodName}}</span>
        <span>{{foodItem.num}}份</span>
        <span class="food-price">￥{{foodItem.price.toFixed(2)}}</span>
    </div>
    <div id="footer">
    <div id="BasicInformation">
        <br><span>下单时间: {{order_inPage.data.order_time}}</span>
        <br><span>订单号: {{order_inPage.data.order_number}}</span>
        <br><span>服务厨师信息</span>
        <br><span>名字: {{order_inPage.data.tarUserInfo.userVO.userName}}</span>
        <br><span>电话: {{order_inPage.data.tarUserInfo.userVO.tel}}</span>
        <br><span>地址: {{order_inPage.data.tarUserInfo.userVO.locate}}</span>
    </div>
    <div id="contact">
      <span style="display: flex; flex-direction: column; align-items: flex-end;">
   <span>总价:</span>
   <span class="total-price">￥{{order_inPage.data.totalPrice.toFixed(2)}}</span>
    </span>
        <button id="evaluation" @click="showEvaluationDialog">评价</button>
        <button id="phone" @click="goToChatPage">联系商家</button>
    </div>
    </div>
    <el-dialog v-model="evaluationDialogVisible" title="用户评价">
        <el-form>
            <el-form-item prop="user_name">
                <el-input
                    v-model="xxxx" prefix-icon="Avatar" placeholder="请输入评价内容"
                    :rows="2"
                    type="textarea"
                />
<!--                <el-input v-model="xxxx" prefix-icon="Avatar" placeholder="请输入评价内容"/>-->
            </el-form-item>
            <div style="text-align: center;">
                <el-button type="success" plain style="margin-left: 70px" @click="Register" >提交</el-button>
            </div>
        </el-form>
    </el-dialog>
</el-card>
</template>
<script setup>
import {getCurrentInstance, onMounted, reactive, ref} from 'vue';
import {useRoute} from "vue-router";
import router from "@/components/router";
const { proxy } = getCurrentInstance();
let xxxx = ref()
let cutId = ref()
const evaluationDialogVisible = ref(false);
const showEvaluationDialog = () => {
    evaluationDialogVisible.value = true;
};
let order_inPage=reactive(
    {
        "data":[],
    }
)
const queryInfo = () => {
    let path = `${proxy.serCtx}/order/orderById`
    proxy.$axios.get(path, {
        params:{
            id: cutId
        }
    }).then((res) => {
        order_inPage.data = res.data;
    })
}
onMounted(()=>{
    const route = useRoute()
    cutId = route.params.id   //将获取的id传递到后端进行匹配
    queryInfo();
})
//聊天跳转逻辑修改优化
const goToChatPage = () => {
  router.push({
    path: '/cookChat',
    query: {
      cookName: order_inPage.data.user_name
    }
  });
};
</script>

<style scoped>
#order_in_container{
    background-color: white;
    /*width: 500px;*/
}
#store{
    height: 80px;
    display: flex;
    align-items: center;
    padding: 5px;
    border-bottom: 1px black solid;
}
#store >img{
    height: 80px;
    line-height: 80px;
    /*padding: 10px 10px;*/
    border-radius: 10px;
}
#commodity{
    display: flex;
    align-items: center;
    padding: 5px;
    border-bottom: 1px black solid;
}
#commodity > *{
    height: 60px;
    margin: 0 10px;
}
#commodity >span{
    height: auto;
}
#commodity > img{
    border-radius: 8px;
}
#contact{
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#contact >span{
    height: auto;
}
#contact >*{
    text-decoration: none;
    margin: 5px 10px;
}
#evaluation{
    background-color: #4BBB90;
    color: white;
    border-radius: 4px;
    padding: 5px 33px;
  border: transparent;
}
#evaluation:hover{
    background-color: #1D815B;
}
#phone{
    background-color: #4BBB90;
    color: white;
    border-radius: 4px;
    padding: 5px 20px;
    text-decoration: none;
  border: transparent;
}
#phone:hover{
    background-color: #1D815B; ;
}
#footer{
    display: flex;
    justify-content: space-between;
}
.food-picture{
  width: 60px;
  height: 60px;
}

.food-commodity{
  display: flex;
  justify-content: space-between;
}

.food-price{
  text-align: right;
  color: #1D815B;
  font-weight: bold;
}
.total-price{
  text-align: right;
  color: #1D815B;
  font-weight: bold;
  font-size: 24px;
}
</style>